#include <sched.h>
#include <unistd.h>
#include <monitor.h>
#include <QApplication>
#include <QMessageBox>
#include <iostream>
#include <stdio.h>

int main(int argc, char *argv[])
{
    // 设置CPU亲和性到指定核心
    cpu_set_t cpuset;
    CPU_ZERO(&cpuset);
    int core_id = 0; // 修改此处为指定的核心编号
    CPU_SET(core_id, &cpuset);

    pid_t pid = getpid();
    if (sched_setaffinity(pid, sizeof(cpu_set_t), &cpuset) == -1)
    {
        perror("sched_setaffinity failed");
        return 1;
    }

    QApplication app(argc, argv);
    app.setApplicationName("Monitor Overlay");
    app.setApplicationVersion("0.0.1");

    try 
    {
        Monitor m;
        app.setActiveWindow(&m);
        m.show();
        return app.exec();
    } 
    catch (const std::exception& e) 
    {
        QMessageBox::critical(nullptr, "Error", QString("Failed to start: %1").arg(e.what()));
        return -1;
    }
}
